package com.yn.front.driver;

import com.yn.common.request.sc.CarManageRequest;
import com.yn.common.response.sc.BaseResult;
import com.yn.service.zy.TCarManageService;
import com.yn.service.zy.model.dto.TCarManageDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/tcarmanage/driver")
@Api(tags = "车辆-司机 相关接口")
public class CarManageController {
    @Autowired
    private TCarManageService tCarManageService;

    /**
     * 根据id查询车辆信息——用于编辑回显
    * */
    @ApiOperation("根据id查询车辆信息")
    @GetMapping("/info")
    public BaseResult<TCarManageDTO> getInfo(@ApiParam("车辆id") @RequestParam @NotNull Integer id) {
        return BaseResult.success(tCarManageService.getInfo(id));
    }


    /**
     * 展示所有车队名称——用于添加司机选择车队
     * key——id
     * value——车队名称
     * */

    @ApiOperation("展示所有车队名称")
    @GetMapping("/fleet/info")
    public BaseResult<Map<Integer, String>> getFleetName() {
        return BaseResult.success(tCarManageService.getFleetName());
    }

    /**
     * 添加司机
     * @param request
     * @param fleetManageId
     * 用户在成为司机时进入其他车队
     */
    @PostMapping("/save")
    @ApiOperation(value = "司机端添加司机")
    public BaseResult<String> save(@RequestParam(value = "fleetManageId",required = true) Integer fleetManageId,
            @RequestBody @Validated CarManageRequest request){
        tCarManageService.saveDriver(request,fleetManageId);
        return BaseResult.success();
    }

    /**
     * 添加司机
     *
     * @param fleetManageId
     * 当前用户已经成为司机想加入其他队或者转队
     */
   /* @PostMapping("/transport/save")
    @ApiOperation(value = "添加司机——转队")
    public BaseResult<String> save2OtherFleet(@RequestParam(value = "fleetManageId",required = false) Integer fleetManageId
                                  ){
        tCarManageService.saveDriver2OtherFleet(fleetManageId);
        return BaseResult.success();
    }*/

}
